home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / program / jfklib.zip / MDI.CPP < prev    next >
Text File  |  1991-05-11  |  2KB  |  144 lines

  1. /*
  2.     MDI.CPP - (C) 1990 by Joachim Kainz 'On a mission from Bhudda'
  3. */
  4.     #include "mdi.hpp"
  5.  
  6.     HWND MDI::hMDIClient = NULL;
  7.  
  8.     EXPORT MDI::MDI (
  9.             int         nCmdShow,
  10.             int         x,
  11.             int         y,
  12.             int         cx,
  13.             int         cy,
  14.             long     lStyle,
  15.             LPSTR    lpName,
  16.             LPSTR     lpMenu,
  17.             long     lExStyle,
  18.             WORD     wStyle,
  19.             HCURSOR     hCursor,
  20.             HICON     hIcon,
  21.             HBRUSH     hBackGrnd,
  22.             WORD     wClsExtra,
  23.             WORD     wWndExtra,
  24.             LPSTR     lpParam,
  25.             LPSTR     lpClass,
  26.             FARPROC2 lpFnProc
  27.     ) : TOPLEVEL (
  28.             SW_HIDE,
  29.             x,
  30.             y,
  31.             cx,
  32.             cy,
  33.             lStyle,
  34.             lpName,
  35.             lpMenu,
  36.             lExStyle,
  37.             wStyle,
  38.             hCursor,
  39.             hIcon,
  40.             hBackGrnd,
  41.             wClsExtra,
  42.             wClsExtra,
  43.             lpParam,
  44.             lpClass,
  45.             lpFnProc
  46.         )
  47.     {
  48.         if (hMDIClient != NULL)
  49.             return;                // Only one MDI-Window is allowed!
  50.  
  51.         if (!GetWindowHandle ())
  52.             return;
  53.  
  54.         // Erzeugen des MDI-Client-Windows
  55.  
  56.         CLIENTCREATESTRUCT ccs;
  57.  
  58.         ccs.hWindowMenu     = NULL;
  59.         ccs.idFirstChild = ID_MDICHILD;
  60.  
  61.         hMDIClient = CreateWindow (
  62.                         "mdiclient",
  63.                         NULL,
  64.                         WS_MDICLIENT,
  65.                         0,
  66.                         0,
  67.                         0,
  68.                         0,
  69.                         GetWindowHandle (),
  70.                         0,
  71.                         GetInstance (),
  72.                         (LPSTR) &ccs
  73.                      );
  74.  
  75.         if (!GetMDIClient ())
  76.             return;
  77.  
  78.         msg.SetMDIMode (GetWindowHandle (), GetMDIClient ());
  79.         ShowWindow     (GetMDIClient    (), SW_SHOW        );
  80.  
  81.         if (nCmdShow != SW_HIDE)
  82.             ShowWindow (GetWindowHandle (), nCmdShow);
  83.     }
  84.  
  85.     HMENU EXPORT MDI::MDISetMenu (HMENU hNewAppMenu, HMENU hNewPopUp)
  86.     {
  87.         HMENU hOld =
  88.                 (HMENU) SendMessage (
  89.                             GetMDIClient (),
  90.                             WM_MDISETMENU,
  91.                             NULL,
  92.                             MAKELONG (hNewAppMenu, hNewPopUp)
  93.                         );
  94.         DrawMenuBar (GetWindowHandle ());
  95.  
  96.         return hOld;
  97.     }
  98.  
  99.     HWND EXPORT MDI::GetNextChild (HWND hChild)
  100.     {
  101.         if (hChild)
  102.             hChild = GetWindow (hChild, GW_HWNDNEXT);
  103.  
  104.         else
  105.             hChild = GetWindow (GetMDIClient (), GW_CHILD);
  106.  
  107.         while (hChild) {
  108.  
  109.             if (!GetWindow (hChild, GW_OWNER))
  110.                 break;
  111.  
  112.             hChild = GetWindow (hChild, GW_HWNDNEXT);
  113.  
  114.         }
  115.  
  116.         return hChild;
  117.     }
  118.  
  119.     long EXPORT MDI::SendAllChildren(
  120.                         WORD wMsg,
  121.                         WORD wParam,
  122.                         long lParam,
  123.                         BOOL bBreakOnFalse
  124.                      )
  125.     {
  126.         long lReturn;
  127.         HWND hChild,
  128.              hNext;
  129.  
  130.         for (hChild=GetNextChild (); hChild; hChild = hNext) {
  131.  
  132.             hNext = GetNextChild (hChild);
  133.  
  134.             lReturn = SendMessage (hChild, wMsg, wParam, lParam);
  135.  
  136.             if (!lReturn && bBreakOnFalse)
  137.                 return NULL;
  138.  
  139.         }
  140.  
  141.         return lReturn;
  142.     }
  143.  
  144.